#!/bin/bash

# 目标目录路径
dir="/Users/ben/IdeaProjects/varian"

# 检查目录是否存在
if [ ! -d "$dir" ]; then
    echo "Error: Directory '$dir' does not exist."
    exit 1
fi

# 定义递归删除函数
delete_target_dirs() {
    local path="$1"
    # 查找并删除所有的 target 目录
    find "$path" -type d -name 'target' -exec rm -rf {} \;
}

# 调用函数
delete_target_dirs "$dir"

echo "All 'target' directories and their contents in '$dir' have been deleted."
